import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        //创建前缀和数组
        int[] dp = new int[n + 1];

        for (int i = 1; i < n + 1; i++) {
            dp[i] = dp[i - 1] + arr[i - 1];
        }

        int m = scanner.nextInt();
        while (m > 0) {
            m--;
            int left = scanner.nextInt();
            int right = scanner.nextInt();
            System.out.println(dp[right] - dp[left - 1]);
        }

        scanner.close();
    }
}
